package com.example.mobile2021606177cke0427;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import java.util.List;

public class ParkingRVAdapter extends RecyclerView.Adapter <ParkingRVAdapter.ViewHolder>{
    private List<Parking> list;
    private ParkingRVAdapter(List<Parking> list) { this.list = list; }

    static class ViewHolder extends RecyclerView.ViewHolder {
        ImageView ivp;
        TextView tvname, tvkongwei, tvprice, tvjuli, tvdizhi, tvmes;
        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            ivp=itemView.findViewById(R.id.iv_item_p);
            tvname=itemView.findViewById(R.id.tv_item_name);
            tvkongwei=itemView.findViewById(R.id.tv_item_kongwei);
            tvprice=itemView.findViewById(R.id.tv_item_price);
            tvjuli=itemView.findViewById(R.id.tv_item_juli);
            tvdizhi=itemView.findViewById(R.id.tv_item_dizhi);
            tvmes=itemView.findViewById(R.id.tv_item_mes);
        }
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view= LayoutInflater.from(parent.getContext())
                .inflate(R.layout.item_rv_main_parking,parent,false);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
       Parking parking=list.get(position);
       holder.tvname.setText(parking.getName());
       holder.tvkongwei.setText(parking.getKongwei());
       holder.tvprice.setText(parking.getPrice());


    }

    @Override
    public int getItemCount() {
        return list.size;
    }


    }
}
